******************************************************
***************** Table 1 *****************

use "${ddata}/cleaned_data_wACSweight.dta", clear


forvalues i = 0/5 { 

	sum qs2_`i' [aw=weight_ACS] if control==1 & qs2_`i'!=.
	local sd_fo_`i' = "`: di %3.2f r(sd)'" 
	local mean_fo_`i' = "`: di %3.2f r(mean)'" 
	local n_`i' = "`: di %3.0f r(N)'" 

}


forvalues i = 0/5 { 

	sum so_mother_time_off_`i' [aw=weight_ACS] if control==1 & so_mother_time_off_`i'!=.
	local sd_so_`i' = "`: di %3.2f r(sd)'" 
	local mean_so_`i' = "`: di %3.2f r(mean)'" 

}



forvalues i = 0/5 { 

	sum so_less_fo`i' [aw=weight_ACS] if control==1 & so_mother_time_off_`i'!=.
	local mean_so_less_`i' = "`: di %3.2f r(mean)'" 
	sum so_gap_positive_`i' [aw=weight_ACS] if control==1 & so_mother_time_off_`i'!=.
	local mean_gap_positive_`i' = "`: di %3.2f r(mean)'" 

}



forvalues i = 0/5 { 

	reg so_gap_positive_`i' [aweight=weight_ACS] if control==1
	test _cons=0.5 
	gen p`i' = r(p) if control==1 & so_gap_positive_`i'!=.
	sum p`i' 
	local mean_p_`i' = "`: di %3.2f r(mean)'" 

}



cap file close table
file open table using "${o}Table1_ACSweighted_GK.tex", write replace
file write table "\begin{tabular}{l c c c c c c} \hline\hline"
file write table "&\multicolumn{1}{c}{Mother Rejects}&\multicolumn{5}{c}{Mother takes time off if she earns [...] than spouse}\\" _n
file write table "\cline{3-7} &\multicolumn{1}{c}{Offer}&\multicolumn{1}{c}{15\% Less}&\multicolumn{1}{c}{Same}&\multicolumn{1}{c}{15\% More}&\multicolumn{1}{c}{30\% More}&\multicolumn{1}{c}{50\% More}\\" _n
file write table "\midrule" _n
file write table "First-Order Beliefs (FO)&        `mean_fo_0'&      `mean_fo_1'&       `mean_fo_2'&       `mean_fo_3'&      `mean_fo_4'&       `mean_fo_5'\\" _n
file write table " &       (`sd_fo_0')&       (`sd_fo_1')&       (`sd_fo_2')&       (`sd_fo_3')&       (`sd_fo_4')&       (`sd_fo_5')\\" _n
file write table "Second-Order Beliefs (FO)&        `mean_so_0'&      `mean_so_1'&       `mean_so_2'&       `mean_so_3'&      `mean_so_4'&       `mean_so_5'\\" _n
file write table "&       (`sd_so_0')&       (`sd_so_1')&       (`sd_so_2')&       (`sd_so_3')&       (`sd_so_4')&       (`sd_so_5')\\" _n
file write table "Share SO $ds<$ds FO &        `mean_so_less_0'&      `mean_so_less_1'&       `mean_so_less_2'&       `mean_so_less_3'&      `mean_so_less_4'&       `mean_so_less_5'\\" _n
file write table "Share SO $ds>$ds truth      &        `mean_gap_positive_0'&      `mean_gap_positive_1'&       `mean_gap_positive_2'&       `mean_gap_positive_3'&      `mean_gap_positive_4'&       `mean_gap_positive_5'\\" _n
file write table "P-value: Share SO $ds>$ds truth = 0.5 &        `mean_p_0'&        `mean_p_1'&        `mean_p_2'&        `mean_p_3'&        `mean_p_4'&        `mean_p_5'\\" _n
file write table "\midrule" _n
file write table "Observations        &        `n_0'&        `n_1'&        `n_2'&        `n_3'&        `n_4'&        `n_5' \\"
file write table "\hline\hline" _n
file write table "\end{tabular}" _n
cap file close table


